<?php
/**
 * Created by PhpStorm.
 * User: dell
 * Date: 2017/7/6
 * Time: 11:10
 */
namespace app\admin\model;
use think\Model;

class Area extends Model{
    //获取区域树
    public static  function get_area_tree($arr,$pid=0,$level=0){
        static $tree = [];
        foreach($arr as $key=>$val) {
            if($val['pid'] == $pid) {
                $flg = str_repeat('-',$level);
                $val['name'] = $flg.$val['name'];
                $tree[] = $val;
                static::get_area_tree($arr , $val['id'] ,$level+1);
            }
        }
        return $tree;
    }
}